package com.thtfpc.ssdp;

import java.util.UUID;

public class SSDPDevice {
    private String id;
    private String name;
    private String serviceUrl;
    private String address;
    private int port;
    private String title;
    private Long activeAt;

    public SSDPDevice() {
        id = UUID.randomUUID().toString();
        name = "device-" + id;
        activeAt = System.currentTimeMillis();
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getServiceUrl() {
        return serviceUrl;
    }

    public void setServiceUrl(String serviceUrl) {
        this.serviceUrl = serviceUrl;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public Long getActiveAt() {
        return activeAt;
    }

    public void setActiveAt(Long activeAt) {
        this.activeAt = activeAt;
    }

    public String getUniqueId() {
        return getServiceUniqueId(getAddress(), getPort(), getServiceUrl());
    }

    public static String getServiceUniqueId(String address, int port, String serviceURL) {
        return String.valueOf(address) + ":" + String.valueOf(port) + "," + String.valueOf(serviceURL);
    }

    @Override
    public String toString() {
        return "SSDPDevice{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", serviceUrl='" + serviceUrl + '\'' +
                ", address='" + address + '\'' +
                ", port=" + port +
                ", title='" + title + '\'' +
                '}';
    }
}
